//
//  TomorrowPrepareCell.m
//  ICrEAM
//
//  Created by Cty on 2016/11/09.
//  Copyright © 2016年 mac. All rights reserved.
//

#import "TomorrowPrepareCell.h"

@interface TomorrowPrepareCell()

@end

@implementation TomorrowPrepareCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}
- (UILabel *)time{
    if(!_time){
        _time = [[UILabel alloc]initWithFrame:CGRectMake(0, ActualHeight(16), ActualWidth(270), ActualHeight(34))];
        _time.font = [UIFont systemFontOfSize:ActualWidth(18)];
        
        _time.textAlignment = NSTextAlignmentCenter;
        
        _time.textColor = Color(0x000000);
        
        [self addSubview: _time];
    }
    return _time;
}

- (UILabel *)plateNum{
    if(!_plateNum){
        _plateNum = [[UILabel alloc]initWithFrame:CGRectMake(0, self.time.bottomEdge,ActualWidth(270), ActualHeight(34))];
        _plateNum.font = [UIFont systemFontOfSize:ActualWidth(18)];
        
        _plateNum.textAlignment = NSTextAlignmentCenter;
        
        _plateNum.textColor = Color(0x666666);
        
        
        [self addSubview: _plateNum];
    }
    return _plateNum;
}
- (UILabel *)customerName{
    if(!_customerName){
        
        UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(self.plateNum.rightEdge+ActualWidth(50), ActualHeight(30), ActualWidth(40), ActualHeight(40))];
        imageView.image = [UIImage imageNamed:Appointment_Customer];
        
        
        _customerName = [[UILabel alloc]initWithFrame:CGRectMake(imageView.rightEdge+10, ActualHeight(16),ActualWidth(190), ActualHeight(34))];
        _customerName.font = [UIFont systemFontOfSize:ActualWidth(18)];
        
        _customerName.textAlignment = NSTextAlignmentLeft;
        
        _customerName.textColor = Color(0x000000);
        [self addSubview:imageView];
        [self addSubview: _customerName];
        //右侧分割线
        UIView *view = [[UIView alloc]initWithFrame:CGRectMake(self.plateNum.rightEdge, 0, 1, ActualHeight(100))];
        view.backgroundColor = Color(0xE6E6E6);
        [self addSubview:view];
    }
    return _customerName;
}
- (UILabel *)customerPhone{
    if(!_customerPhone){
        UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(self.plateNum.rightEdge+ActualWidth(50), ActualHeight(30), ActualWidth(40), ActualHeight(40))];
        imageView.image = [UIImage imageNamed:Appointment_Customer];
        [_btnPreview addSubview:imageView];
        _customerPhone = [[UILabel alloc]initWithFrame:CGRectMake(imageView.rightEdge+10, self.customerName.bottomEdge,ActualWidth(190), ActualHeight(34))];
        _customerPhone.font = [UIFont systemFontOfSize:ActualWidth(18)];
        
        _customerPhone.textAlignment = NSTextAlignmentLeft;
        
        _customerPhone.textColor = Color(0x666666);
        
        [self addSubview: _customerPhone];
        
    }
    return _customerPhone;
}
- (UILabel *)assistantName{
    if(!_assistantName){
        
        UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(self.customerName.rightEdge+ActualWidth(50), ActualHeight(30), ActualWidth(40), ActualHeight(40))];
        imageView.image = [UIImage imageNamed:Appointment_Consultant];
        
        _assistantName = [[UILabel alloc]initWithFrame:CGRectMake(imageView.rightEdge+10, ActualHeight(16),ActualWidth(190), ActualHeight(34))];
        _assistantName.font = [UIFont systemFontOfSize:ActualWidth(18)];
        
        _assistantName.textAlignment = NSTextAlignmentLeft;
        
        _assistantName.textColor = Color(0x000000);
        
        [self addSubview: _assistantName];
        //右侧分割线
        UIView *view = [[UIView alloc]initWithFrame:CGRectMake(self.customerPhone.rightEdge, 0, 1, ActualHeight(100))];
        view.backgroundColor = Color(0xE6E6E6);
        [self addSubview:imageView];
        [self addSubview:view];
    }
    return _assistantName;
}
- (UILabel *)assistantPhone{
    if(!_assistantPhone){
        
        UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(self.customerName.rightEdge+ActualWidth(50), ActualHeight(30), ActualWidth(40), ActualHeight(40))];
        imageView.image = [UIImage imageNamed:Appointment_Consultant];
        
        _assistantPhone = [[UILabel alloc]initWithFrame:CGRectMake(imageView.rightEdge+10, self.assistantName.bottomEdge,ActualWidth(190), ActualHeight(34))];
        _assistantPhone.font = [UIFont systemFontOfSize:ActualWidth(18)];
        
        _assistantPhone.textAlignment = NSTextAlignmentLeft;
        
        _assistantPhone.textColor = Color(0x666666);
        
        [self addSubview: _assistantPhone];
    }
    return _assistantPhone;
}
- (UIButton *)btnPreview{
    
    if(!_btnPreview){
        _btnPreview = [[UIButton alloc]initWithFrame:CGRectMake(self.assistantPhone.rightEdge+ActualWidth(60), ActualHeight(25), ActualWidth(50), ActualHeight(55))];
        UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(ActualWidth(10), 0, ActualHeight(30), ActualWidth(30))];
        imageView.image = [UIImage imageNamed:Common_Preview];
        [_btnPreview addSubview:imageView];
        
        UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, imageView.bottomEdge+5, ActualWidth(50), ActualHeight(20))];
        [_btnPreview addSubview:label];
        label.text = @"预览";
        label.textColor = TitleColor;
        label.textAlignment = NSTextAlignmentCenter;
        [_btnPreview addSubview:label];
        [self addSubview: _btnPreview];
        
        [_btnPreview addTarget:self action:@selector(didClickPreviewButton) forControlEvents:UIControlEventTouchUpInside];
        //右侧分割线
        UIView *view = [[UIView alloc]initWithFrame:CGRectMake(self.assistantPhone.rightEdge, 0, 1, ActualHeight(100))];
        view.backgroundColor = Color(0xE6E6E6);
        [self addSubview:view];
        
    }
    return _btnPreview;
}
- (void)didClickPreviewButton{
    
    NSIndexPath *indexPatch = [((UITableView *)self.superview.superview) indexPathForCell:self];
    
    if([self.delegate respondsToSelector:@selector(didClickPreViewWithIndex:)]){
        [self.delegate didClickPreViewWithIndex:indexPatch];
    }
    
}
- (void)updateDataWithModel:(ICMAppointmentPlanModel *)model{
    self.contentView.backgroundColor = Color(0xF1F3F3);
    self.time.text = [ICrEAMTool getDateHourMinuteWithTimeInterval:model.date];
    self.plateNum.text = model.plateNum;
    self.customerName.text = model.customerName;
    self.customerPhone.text = model.customerPhone;
    self.assistantName.text = model.assistantName;
    self.assistantPhone.text = model.assistantPhone;
    self.btnPreview.hidden = NO;
}
@end
